<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/> 
    <title>微信支付</title>
    <script type="text/javascript">
	//调用微信JS api 支付
	function jsApiCall()
	{
		WeixinJSBridge.invoke(
			'getBrandWCPayRequest',
			<?php echo $jsApiParameters; ?>,
			function(res){
				WeixinJSBridge.log(res.err_msg);
				//alert(res.err_code+'|'+res.err_desc+'|'+res.err_msg);
				if(res.err_msg == 'get_brand_wcpay_request:ok'){
					window.location.href = "{:url('Rechargewepay/return_url')}?orderid={$orderid}";
				}else{
					//alert(res.err_code+'|'+res.err_desc+'|'+res.err_msg);
					window.location.href = "{:url('Rechargewepay/return_url')}?orderid={$orderid}";
				}
			}
		);
	}

	function callpay()
	{
		if (typeof WeixinJSBridge == "undefined"){
		    if( document.addEventListener ){
		        document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', jsApiCall); 
		        document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
		    }
		}else{
		    jsApiCall();
		}
	}

	//获取共享地址
	function editAddress()
	{
		WeixinJSBridge.invoke(
			'editAddress',
			<?php echo $editAddress; ?>,
			function(res){
				var value1 = res.proviceFirstStageName;
				var value2 = res.addressCitySecondStageName;
				var value3 = res.addressCountiesThirdStageName;
				var value4 = res.addressDetailInfo;
				var tel = res.telNumber;
				
				//alert(value1 + value2 + value3 + value4 + ":" + tel);
        let f = document.getElementByid('msg').innerHTML;
        f = f = "\n" + value1 + value2 + value3 + value4 + ":" + tel;
        document.getElementByid('msg').innerHTML = f;
        
			}
		);
	}
	
	window.onload = function(){
		if (typeof WeixinJSBridge == "undefined"){
		    if( document.addEventListener ){
		        document.addEventListener('WeixinJSBridgeReady', editAddress, false);
		    }else if (document.attachEvent){
		        document.attachEvent('WeixinJSBridgeReady', editAddress); 
		        document.attachEvent('onWeixinJSBridgeReady', editAddress);
		    }
		}else{
			editAddress();
		}
	};
	</script>
</head>
<style>
*{ margin:0; padding:0; outline:0; box-sizing:border-box;-webkit-box-sizing:border-box; -moz-box-sizing:border-box;}
body{ font-family:'Microsoft Yahei'; background:#ffffff; text-align:center; }
.main{ width:100%; max-width:750px; margin:0 auto; text-align:left; padding:20px;}
.topay{  }
.topay h1{ font-size:18px; color:#333333; line-height:1em; padding:10px 0; }
.topay h2{ font-size:24px; line-height:1em; padding:80px 0 10px; text-align:center; font-weight:normal; }
.topay h2 span{ color:red; }

.topay h3{ font-size:14px; line-height:1em; padding:10px 0 50px; text-align:center; font-weight:normal; }
.topay h3 span{  }

.topay div{ text-align:center; padding-top:20px; }
.topay button{ font-size:14px; line-height:1em; padding:14px 0; width:80%; border:0; background:#ff8630; color:#ffffff; border-radius:5px; }
.result{ text-align:center; padding-top:100px; display:none; }
.result h1{ font-size:24px; line-height:1em; color:green; font-weight:normal; }
.result p{ padding-top:30px; }
.result p a{ color:blue; text-decoration:underline; font-size:14px; }
.failed h1{ color:red; }
</style>

<body>


<p id='msg' style='display:none;'></p>


<script>
callpay();
</script>
</body>
</html>